#include "DoorAcSwitchStatusPage.h"

#include "DoorAlertor.h"
#include "MachineDependents.h"
#include "AcSwitchDetector.h"


DoorAcSwitchStatusPage::DoorAcSwitchStatusPage(const int pageNum) : BasePage(pageNum) {
    mpControllers = &ExtendDeviceManagerSingleton::instance().getExtendDevices(ExtendDeviceEnum::AC_SWITCH_DETECTOR);
}


void DoorAcSwitchStatusPage::paint() {
    std::string content[4];

    resetStream();

    strStream << "AcSwiDetector" << std::right << std::setw(3) << pageNum;// << std::setw(3)
    content[0] = strStream.str();

    if (mpControllers->empty() ) {
        content[1] = ExtendDeviceEnum::NO_DEVICE.name;
    } else {
        ExtendDevicePtr extendDevicePtr = mpControllers->front().lock();
        if (nullptr == extendDevicePtr) {
            content[1] = ExtendDeviceEnum::NO_DEVICE.name;
        } else {
            extendDevicePtr->updateInformation();
            AcSwitchDetector* pSwitchDetector = static_cast<AcSwitchDetector*> (extendDevicePtr->getDevice(ExtendDeviceEnum::AC_SWITCH_DETECTOR));

            content[1] = "transSwitch:" + pSwitchDetector->mswitchMode;
            content[2] = "circuit:" + pSwitchDetector->mloopSwitchStatus;
        }

    }
    screen.show(&content[0], &content[1], &content[2], &content[3]);
}




